/**
 * GENPlusDroid
 * Copyright 2011 Stephen Damm (Halsafar)
 * All rights reserved.
 * shinhalsafar@gmail.com
 *
 * Quad.cpp
 *
 *  Created on: 2011-05-01
 *      Author: halsafar
 */

#include "Quad.h"

Quad2D::Quad2D()
{
     _isVisible = true;
     _vertices = new GLfloat[4*3];
     _texCoords = new GLfloat[4*2];

     _textureId = -1;

     SetDimensions(0, 0, 0, 0);

     _texCoords[0] = 0.0f;    _texCoords[1] = 0.0f;
     _texCoords[2] = 1.0f;    _texCoords[3] = 0.0f;
     _texCoords[4] = 0.0f;    _texCoords[5] = 1.0f;
     _texCoords[6] = 1.0f;    _texCoords[7] = 1.0f;
}

Quad2D::Quad2D(float x, float y, float width, float height)
{
     _vertices = new GLfloat[4*3];
     _texCoords = new GLfloat[4*2];

     _textureId = -1;

     SetDimensions(x, y, width, height);

     _texCoords[0] = 0.0f;    _texCoords[1] = 1.0f;
     _texCoords[2] = 1.0f;    _texCoords[3] = 1.0f;
     _texCoords[4] = 0.0f;    _texCoords[5] = 0.0f;
     _texCoords[6] = 1.0f;    _texCoords[7] = 0.0f;
}

Quad2D::~Quad2D()
{
     delete _vertices;
     _vertices = NULL;

     delete _texCoords;
     _texCoords = NULL;
}


void Quad2D::SetDimensions(float x, float y, float width, float height)
{
     _x = x;
     _y = y;
     _width = width;
     _height = height;

     // generate the screen quad vertices
     _vertices[0] = x;        _vertices[1] = y+height;     _vertices[2] = 0.0;
     _vertices[3] = x+width;  _vertices[4] = y+height;     _vertices[5] = 0.0;
     _vertices[6] = x;        _vertices[7] = y;            _vertices[8] = 0.0;
     _vertices[9] = x+width;  _vertices[10] = y;           _vertices[11] = 0.0;
}


void Quad2D::SetTextureId(GLint id)
{
     _textureId = id;
}
